package com.web.dao;

import com.web.entity.UserCertification;
import org.apache.ibatis.annotations.*;

public interface UserCertificationMapper {
    @Delete({
        "delete from APP_USER_CERTIFICATION",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_USER_CERTIFICATION (user_id, type, ",
        "realname, id_card, ",
        "card_z, card_f, tech_id, ",
        "tech_card, auth_status, ",
        "create_time, modify_time)",
        "values (#{userId,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, ",
        "#{realname,jdbcType=VARCHAR}, #{idCard,jdbcType=VARCHAR}, ",
        "#{cardZ,jdbcType=VARCHAR}, #{cardF,jdbcType=VARCHAR}, #{techId,jdbcType=VARCHAR}, ",
        "#{techCard,jdbcType=VARCHAR}, #{authStatus,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(UserCertification record);

    int insertSelective(UserCertification record);

    @Select({
        "select",
        "id, user_id, type, realname, id_card, card_z, card_f, tech_id, tech_card, auth_status, ",
        "create_time, modify_time",
        "from APP_USER_CERTIFICATION",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    UserCertification selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(UserCertification record);

    @Update({
        "update APP_USER_CERTIFICATION",
        "set user_id = #{userId,jdbcType=VARCHAR},",
          "type = #{type,jdbcType=INTEGER},",
          "realname = #{realname,jdbcType=VARCHAR},",
          "id_card = #{idCard,jdbcType=VARCHAR},",
          "card_z = #{cardZ,jdbcType=VARCHAR},",
          "card_f = #{cardF,jdbcType=VARCHAR},",
          "tech_id = #{techId,jdbcType=VARCHAR},",
          "tech_card = #{techCard,jdbcType=VARCHAR},",
          "auth_status = #{authStatus,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(UserCertification record);

    UserCertification findUserCertification(@Param("key") String key, @Param("value") String value);

}